home *** CD-ROM | disk | FTP | other *** search
/ Windows 3-Pak - Disc 3 / Infomagic - Windows 3-Pak (Disc 3 of 3).iso / Stock-Quotes / quotenow.exe / data.z / wxssrvr.cpp < prev    next >
C/C++ Source or Header  |  1997-04-17  |  7KB  |  214 lines

  1. // wxssrvr.cpp : Defines the initialization routines for the DLL.
  2. // (C)opyright 1996 by Federated Telecommunications Corp.
  3.  
  4. /*
  5. QuotesNow! is trademark and (C)opyright 1996
  6. by Federated Telecommunications Corp. and
  7. Windows Xpert Systems 
  8.  
  9. You or any entity using this code must purchase a copy of QuotesNow!
  10. (tm) for each person that will use this source code.  The purchaser/
  11. registered user may freely distribute compiled derivative
  12. (machine readable code only) versions of this code.
  13.  
  14. Registered Users (Users who have purchased the QuotesNow! (tm) program
  15. from Federated Telecommunications Corp. or Windows Xpert Systems)
  16. Once you have purchased the application, you may use one copy
  17. of the program.  The program is licensed to YOU (the purchaser/user
  18. by name), no other user may legally use the software.
  19. It is understood that you use the software at your own risk.
  20.  Registered Users may produce compiled derivative works of the
  21.  source code provided with this program as long as it's intended use
  22.  is only for use with the QuotesNow! (tm) program by Windows Xpert Systems
  23.  and Federated Telecommunications Corp.  The derivative source code
  24.  may be distributed as long as all notices in all code, including
  25.  copyright and trademark notices remain intact and the author makes it
  26.  clear that the source code may only be used to work with the
  27.  QuotesNow! (tm) program by Windows Xpert Systems and 
  28.  Federated Telecommunications, and that any user of the source code must
  29.  purchase the QuotesNow! (tm) program to use it.  The header files
  30.  (files ending in .h, such as server.h) may not be distributed
  31.  seperately from the QuotesNow! (tm) program.
  32.  The add-in .SRV/.DLL source code itself may only be distributed
  33.  as a derivative work as mentioned above 
  34.  (with all notices intact and the author notifying any potential
  35.  user of the required uses of the source code - only a Registered
  36.  QuotesNow! (tm) user may distribute/use the Source code derivative
  37.  work.)
  38.  
  39.   */
  40.  
  41.  
  42. // This code shows a sample server .dll (.srv) for use
  43. // with the WXSStock client
  44.  
  45. #include "stdafx.h"
  46. #include <afxdllx.h>
  47. #include "resource.h"
  48. #define _SERVER_DLL
  49. #include "..\..\server.h"
  50.  
  51.  
  52. #ifdef _DEBUG
  53. #define new DEBUG_NEW
  54. #undef THIS_FILE
  55. static char THIS_FILE[] = __FILE__;
  56. #endif
  57.  
  58. HINSTANCE g_hInstance;
  59.  
  60. static AFX_EXTENSION_MODULE WxssrvrDLL = { NULL, NULL };
  61.  
  62. //defines to simplify calling helper functions
  63. #define GetTagS    (*wxsinfo.lpfnGetTagS)
  64. #define GetTableItems (*wxsinfo.lpfnGetTableItems)
  65. #define SplitStringDash (*wxsinfo.lpfnSplitStringDash)
  66. #define FixupNumber    (*wxsinfo.lpfnFixupNumber)
  67. #define FindDataField (*wxsinfo.lpfnFindDataField)
  68. #define GetNumberAndFraction (*wxsinfo.lpfnGetNumberAndFraction)
  69. #define RegisterFileFormat (*wxsinfo.lpfnRegisterFileFormat)
  70. #define RegisterWebLink (*wxsinfo.lpfnRegisterWebLink)
  71. #define AddMenuOption(structure)    (*wxsinfo.lpfnFunctionInterface)((DWORD)FSI_ADDMENUOPTION,(void *)structure)
  72.  
  73. #define WXSFunctionCall (*wxsinfo.lpfnFunctionInterface)
  74. #define WXSFunctionCallEx(func,structure) (*wxsinfo.lpfnFunctionInterface)((DWORD)func,(void *)structure)
  75.  
  76.  
  77.  
  78. extern "C" __declspec(dllexport) BOOL WeblinkCallback(DWORD dwSettings,const char *lpszRSymbol,
  79.                                           const char *lpszTitle,
  80.                                           DWORD dwUserValue);
  81.  
  82.  
  83.  
  84. //globally defined structure so that our helper function
  85. //macros will work
  86. WXSINFO wxsinfo;
  87.  
  88.  
  89. extern "C" int APIENTRY
  90. DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  91. {
  92.     if (dwReason == DLL_PROCESS_ATTACH)
  93.     {
  94.         TRACE0("WXSSRVR.DLL Initializing!\n");
  95.         
  96.         g_hInstance=hInstance;
  97.         // Extension DLL one-time initialization
  98.         AfxInitExtensionModule(WxssrvrDLL, hInstance);
  99.  
  100.         // Insert this DLL into the resource chain
  101.         new CDynLinkLibrary(WxssrvrDLL);
  102.     }
  103.     else if (dwReason == DLL_PROCESS_DETACH)
  104.     {
  105.         TRACE0("WXSSRVR.DLL Terminating!\n");
  106.     }
  107.     return 1;   // ok
  108. }
  109.  
  110.  
  111. //WxsGetApiVersion required function
  112. extern "C" __declspec(dllexport) float WxsGetApiVersion()
  113. {
  114.     return (float)WXSSERVER_APIVERSION;
  115. }
  116.  
  117.  
  118. //WxsServerInit required function
  119. extern "C" __declspec(dllexport) BOOL WxsServerInit(CServerObject *srv,float fApiVersion,int iCServerObject,
  120.                                                     WXSINFO *pwxs)
  121. {
  122.     
  123.  
  124.     
  125.  
  126.     HINSTANCE hInst=AfxGetResourceHandle();
  127.  
  128.     
  129.     //This is true only if the client exactly matches how the .DLL
  130.     //was compiled.  (This can be different when the .DLL
  131.     //version doesn't match the client version) Though it could be
  132.     //the same.  Depends on whether or not we have made changes to
  133.     //the CServerObject data strcuture for a prticular version
  134.     //this test is only for our sanity test purposes.
  135.     //If possible you should handle older versions of the client
  136.     //so this ASSERT(sizeof(CServerObject)==iCServerObject);
  137.     //should not be included at runtime and you may need to remove
  138.     //it for testing purposes to test with different versions of
  139.     //the client
  140.     if (sizeof(CServerObject)!=iCServerObject)
  141.     {
  142.         //ASSERT(sizeof(CServerObject)==iCServerObject);
  143.         return FALSE;
  144.     }
  145.  
  146.     //set the resourceHandle to point to this .DLL
  147.     AfxSetResourceHandle(g_hInstance);
  148.  
  149.     //save the helper function pointers in the
  150.     //global structure.  Need to save these here as the
  151.     // pointer to the WXSINFO structure (pwxs) will be invalid
  152.     //after this function completes.
  153.     wxsinfo.lpfnGetTagS=pwxs->lpfnGetTagS;
  154.     wxsinfo.lpfnGetTableItems=pwxs->lpfnGetTableItems;
  155.     wxsinfo.lpfnSplitStringDash=pwxs->lpfnSplitStringDash;
  156.     wxsinfo.lpfnFixupNumber=pwxs->lpfnFixupNumber;
  157.     wxsinfo.lpfnFindDataField=pwxs->lpfnFindDataField;
  158.     wxsinfo.lpfnGetNumberAndFraction=pwxs->lpfnGetNumberAndFraction;
  159.     wxsinfo.lpfnRegisterWebLink=pwxs->lpfnRegisterWebLink;
  160.     wxsinfo.lpfnFunctionInterface=pwxs->lpfnFunctionInterface;
  161.  
  162.     //store the strings and data into the server object
  163.     //so it can be returned to the client
  164.     srv->m_dwSize=sizeof(CServerObject);
  165.     srv->m_sServerName.LoadString(IDS_NNAME_SCHWAB);    
  166.     srv->m_httpAddress.LoadString(IDS_SSERVER_SCHWAB);
  167.     srv->m_httpSQuoteFormat.LoadString(IDS_SSERVER_SCHWAB_REQ);
  168.     srv->m_httpGraphFormat.LoadString(IDS_GSERVER_SCHWAB);
  169.     srv->m_httpNewsFormat="";
  170.     srv->m_httpHistoricalDataFormat="";
  171.     srv->m_httpSTickerLookupFormat="";
  172.     srv->m_httpStockHomePageFormat="";
  173.     srv->m_lpParseCallback=NULL;
  174.         //(SERVERPARSE_CALLBACK)ParsePrNewsWireNewsServer;
  175.     srv->m_httpOQuoteFormat="";
  176.     srv->m_srvCaps=CServerObject::SRV_CAP_GRAPH;
  177.     srv->m_dwBufferSize=0;    //use default buffer
  178.  
  179.     //if we know we can handle older versions of API with this
  180.     //.DLL we can assign m_fApiVersion=fApiVersion passed in
  181.     //so that the client won't complain about an inproper version
  182.     srv->m_fApiVersion=(float)WXSSERVER_APIVERSION;
  183.  
  184.     //Test code to show how web links work
  185.     //This can be uncommented out to show how web links
  186.     //can be added via an add-in .srv/.dll file
  187.     /*RegisterWebLink(RWL_WXSALLSYMBOLS,
  188.         "Test Title from WXSSRVR",
  189.         (LPCTSTR)srv->m_sServerName,
  190.         "",
  191.         (WEBLINK_CALLBACK)WeblinkCallback,
  192.         0);*/
  193.  
  194.  
  195.     //restore the resource handle back to the client .DLL
  196.     AfxSetResourceHandle(hInst);
  197.  
  198.     return TRUE;
  199. }
  200.  
  201. //This code is for showing how web link callbacks
  202. //can be handled
  203. extern "C" __declspec(dllexport) BOOL WeblinkCallback(DWORD dwSettings,const char *lpszRSymbol,
  204.                                           const char *lpszTitle,
  205.                                           DWORD dwUserValue)
  206. {
  207.     
  208.     AfxMessageBox("Got callback!",MB_OK);
  209.  
  210.     return TRUE;
  211. }
  212.  
  213.  
  214.